package cz.hanis.android.pubaccounting.db.tables;

import android.database.sqlite.SQLiteDatabase;
import android.provider.BaseColumns;


public final class PubTable {


	   public static final String TABLE_NAME = "pub";

	   public static class PubColumns implements BaseColumns {	      
	      public static final String NAME = "name";
	      public static final String ADDRESS = "address";
	      public static final String HOMEPAGE = "homepage";
	      public static final String LONGITUDE = "longitude";
	      public static final String LATITUDE = "latitude";
	   }

	   public static void onCreate(SQLiteDatabase db) {
	      StringBuilder sb = new StringBuilder();

	      sb.append("CREATE TABLE " + PubTable.TABLE_NAME + " (");
	      sb.append(PubColumns._ID + " INTEGER PRIMARY KEY, ");
	      sb.append(PubColumns.NAME + " TEXT UNIQUE NOT NULL, ");
	      sb.append(PubColumns.ADDRESS + " TEXT, ");
	      sb.append(PubColumns.HOMEPAGE + " TEXT, ");
	      sb.append(PubColumns.LONGITUDE + " REAL, ");
	      sb.append(PubColumns.LATITUDE + " REAL");
	      sb.append(");");
	      db.execSQL(sb.toString());
	   }

	   public static void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
	      db.execSQL("DROP TABLE IF EXISTS " + PubTable.TABLE_NAME);
	      PubTable.onCreate(db);
	   }	
	
	
}
